package test.java.snapshot;

import main.java.chessfootball.model.game.*;
import main.java.chessfootball.model.regulation.Period;
import main.java.chessfootball.model.rule.GameRule;
import main.java.chessfootball.model.rule.MatchRule;
import main.java.chessfootball.model.rule.Rule;
import main.java.chessfootball.model.rule.TimeRule;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Igor
 * Date: 27.07.2011
 * Time: 7:27:45
 */
public class GameSnapshot
{
	public static Game startGameTwoTimes()
	{
		GameRule gameRule = new GameRule(true, 8, true, true, 3, true);
		List<TimeRule> times = new ArrayList<TimeRule>();
		times.add(new TimeRule(Period.FT, 45, false, false, false));
		times.add(new TimeRule(Period.ST, 45, false, false, false));
		Uniform[] uniforms = new Uniform[2];
		uniforms[0] = Uniform.BLUE;
		uniforms[1] = Uniform.RED;
		MatchRule matchRule = new MatchRule(times, 11, 10, null, Side.HOME, Half.RIGHT, uniforms);
		Rule rule = new Rule(gameRule, matchRule);
		Game game = new Game(rule);
		return game;
	}


	public static Game startGameTwoTimes11Players()
	{
		Game game = startGameTwoTimes();
		game.getField().formation(FieldSnapshot.TEST);
		return game;
	}

	public static Game playGameFirstTime()
	{
		Game game = startGameTwoTimes11Players();
		game.turn();
		return game;
	}

	public static Game startMiniGame()
	{
		GameRule gameRule = new GameRule(true, 8, true, true, 3, true);
		List<TimeRule> times = new ArrayList<TimeRule>();
		times.add(new TimeRule(Period.FT, 5, false, false, false));
		times.add(new TimeRule(Period.ST, 5, false, false, false));
		Uniform[] uniforms = new Uniform[2];
		uniforms[0] = Uniform.BLUE;
		uniforms[1] = Uniform.RED;
		MatchRule matchRule = new MatchRule(times, 3, null, null, Side.HOME, Half.RIGHT, uniforms);
		Rule rule = new Rule(gameRule, matchRule);
		Game game = new Game(rule);
		return game;
	}

	public static Game startMiniGame2()
	{
		GameRule gameRule = new GameRule(false, 8, false, false, 3, false);
		List<TimeRule> times = new ArrayList<TimeRule>();
		times.add(new TimeRule(Period.FT, 5, false, false, false));
		times.add(new TimeRule(Period.ST, 5, false, false, false));
		Uniform[] uniforms = new Uniform[2];
		uniforms[0] = Uniform.BLUE;
		uniforms[1] = Uniform.RED;
		MatchRule matchRule = new MatchRule(times, 3, null, null, Side.HOME, Half.RIGHT, uniforms);
		Rule rule = new Rule(gameRule, matchRule);
		Game game = new Game(rule);
		return game;
	}

	public static Game startIterativeOutGame()
	{
		GameRule gameRule = new GameRule(true, 8, true, true, 3, true);
		List<TimeRule> times = new ArrayList<TimeRule>();
		times.add(new TimeRule(Period.FT, 5, false, false, true));
		Uniform[] uniforms = new Uniform[2];
		uniforms[0] = Uniform.BLUE;
		uniforms[1] = Uniform.RED;
		MatchRule matchRule = new MatchRule(times, 3, null, null, Side.HOME, Half.RIGHT, uniforms);
		Rule rule = new Rule(gameRule, matchRule);
		Game game = new Game(rule);
		return game;
	}
}
